package com.tang.controller;

import com.tang.dto.UserInfoDto;
import com.tang.sys.ResponseResult;
import com.tang.sys.entity.User;
import com.tang.sys.service.IUserService;
import com.tang.sys.vo.PageVo;
import com.tang.sys.vo.UserAdminVo;
import com.tang.sys.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/user")
public class AdminUserController {
    @Autowired
    private IUserService iUserService;

    @GetMapping("/list")
    public ResponseResult<PageVo> adminUserList(Integer pageNum, Integer pageSize, UserInfoDto userInfoDto) {

        return iUserService.adminUserList(pageNum,pageSize,userInfoDto);
    }
    //新增
    @PostMapping
    public ResponseResult addUserList(@RequestBody User user){
        iUserService.addUserList(user);
        return ResponseResult.okResult(user);
    }
    //获取信息
    @GetMapping("{id}")
    public ResponseResult getUserById(@PathVariable("id") String id){

        return iUserService.getUserById(id);
    }
    //实现修改
    @PutMapping
    public ResponseResult UpdateUserById(@RequestBody User user){

        return iUserService.UpdateUserById(user);
    }


    //删除
    @DeleteMapping("{id}")
    public ResponseResult deleteUserById(@PathVariable("id") Long id){

        return iUserService.deleteUserById(id);
    }
    //状态修改
    @PutMapping("/changeStatus")
    public ResponseResult<UserVo> updateStatus(@RequestBody UserVo userVo){

        return iUserService.updateStatus(userVo);
    }
}
